其他

Cracking the Code: How Kids Can Write Their Own Video Game

2018-04-26 ANDREW KILLEEN beijingkids

We give you all the essentials in Beijing, from events to news to community connections.

For many parents, video games are a source of concern. They’re seen as a distraction from homework, as interfering with healthy active play; and for parents who don’t play games themselves, they’re a secret and mysterious world, where children might be subject to undesirable influences.


But games are part of our culture now, and increasingly becoming a valid means of artistic expression. Blockbuster games are as expensively and elaborately produced as movies, while the “indie” scene can be experimental and subversive. And it’s a massive global industry, expected to grow from USD 116 billion in 2017 to USD 143.5 billion by 2020.


So if our children are into video games, perhaps we should be encouraging them to start creating instead of just playing. But can kids cope with the complexities of computer code? The founders of “Kids Can Code!” workshops believe they can. I took my boys Noah (aged 12) and Joseph (9) along to find out.


The workshop takes place at a cafe in Sanlitun, and is led by professional software engineer Fernando Colaco. Colaco tells the kids that he began coding at the age of 14. Like many of his generation, he taught himself to program a ZX Spectrum, and this led to a successful career.


“The great thing about coding is that you can work anywhere,” he says. “All you need is a laptop.”


He backs up this message with a short video about the importance of coding. There is a global skills shortage in computer software, we learn, so coding can be lucrative as well as fun.


“Coders are the wizards of the future!” the video says. “It’s like having superpowers.”


Having got the kids motivated, Colaco explains what’s involved in the workshop. Children are often taught “Scratch” coding, which involves dragging and dropping blocks which represent instructions, but this workshop is different.


Green Robot and Red Robot carry out their instructions.

“We’re going to put our hands on real code,” Colaco says.


The language used is Action Script 3, which can export to both Android and iOS.


“But the focus isn’t on the language, it’s just a tool,” Colaco says. He shows the same code in five different languages; the differences are minimal, the basic structure identical.


“We need to use a language,” he says, “but it’s easy to change to different languages. Coding isn’t complicated, because the computer is dumb. You have to tell it what to do.”


As a demonstration of this, he gets my boys to put on robot heads and carry out sequences of instructions, causing much hilarity. But amid the laughter some basic concepts of coding are being taught: variables, functions, conditions, loops, and events. And there’s another important principle being conveyed.


“If something fails,” Colaco says, “you can’t blame the computer! It’s just doing what you told it to do.”
I look anxiously at Joseph, a perfectionist who hates to make mistakes.


“Bugs happen,” Colaco continues. “Solving them is satisfying.”


Having loaded up the software and shown some basic ways of moving around it, Colaco hands out pens and paper.


“Now we’re going to brainstorm ideas,” he says. 


“Coding isn’t just a technical thing, it’s a creative process.”


During the workshop, the children are going to create a game. Although each of them has their own laptop and writes their own code, they’ll be working collaboratively. Colaco tells them to go wild and be imaginative, and the kids take him at his word.


“It’s going to be about a pig ninja,” Joseph proclaims. “He shoots ninja stars with his tail and has swords in his ears. He has to defeat the Truffle Guardians and their giant Robo-Sheep.”


As the children talk they draw pictures, and the ideas really begin to flow.


“The pig’s so powerful, it has to have some challenge…”


“A salamander army! No, a platypus- now we’re talking. An echidna that shoots spines!”


After ten minutes, the game has a name. It’s called Oinkmaster: Ninja Pirate Pig Pandemonium.


After this flurry of creativity, the kids take a break and blow off steam. Then the real business of coding begins.


They start with a simple button, and learn how to use X and Y coordinates to put it in different places on the screen. Then they create labels with their names on, and are challenged to put them in specified places. The kids grasp the concepts intuitively; when one label disappears, they realize immediately that the coordinates are too large and it’s off the screen.


By lunchtime, they’re already writing code. During the break, Colaco is busy scanning their pictures, and when they return, Oinkmaster has appeared on their screens, to their great delight.


Oinkmaster (lower right) defends his island against his foes.

Colaco has also created an island for the ninja pig to defend, and the first challenge is to make Oinkmaster the right size and put him on his island. The kids quickly apply their learning, and complete the task. The next step is to get him moving from side to side, patrolling his territory.


Up till now, the pig has been a single image moving around the screen, but Colaco explains that if Oinkmaster is to be animated, then he needs to be broken up into different pieces and reassembled. The process of putting his head, body, legs, and tail back together is accompanied by fits of giggles; if the kids get the numbers wrong, then parts of him are left floating in space. I am delighted to see that Joseph is unconcerned by making mistakes, able to laugh at the unintended outcome and then find and fix the problem. Even this perfectionist finds bug hunting fun.


By the end of the day, the kids are able to make torrents of spinning pigs fall from the sky. The next morning there is much work left to do in the game, and they draw up a list of priority tasks.


Colaco has animated Oinkmaster overnight, so that the pig’s legs now move as he walks. The first job is to get him under control, so that he moves in response to a finger on the screen. The kids are confident enough with the code now that they tinker with other things too: changing the color of the evil echidnas, for example. It’s fascinating to see how they help and teach each other, swapping lines of code.


“How do you make the ninja star small?”


“Delete every line that makes it big.”


At one point Noah writes a different line of code to the one Colaco is demonstrating.


“No, you don’t need that part,” Colaco says.


“Yes, you do,” Noah replies confidently. “It won’t work otherwise.”


Colaco tests his code, and finds that Noah is right. Philip Johnson, co-founder of Kids Can Code!, is watching too.


“This is why it has to be a two-day workshop,” he tells me. “We get requests to do one hour, but you don’t get that ‘I can do this’ moment.”


Joseph decides he wants Oinkmaster’s tail-mounted ninja star to shoot off and come back like a boomerang.


Making it fly is easy; getting it to return is a bit more tricky.


“My ninja star won’t come back to my butt!” he complains.


“That’s not something you hear often,” Noah drily observes.


If our children are into video games, perhaps we should be encouraging them to start creating instead of just playing. 

There’s a similar problem with the pig. When they make him jump, he flies up in the air but is never seen again. What goes up doesn’t necessarily come down, we learn, but we’ve also proved that pigs can fly. It’s back to the code to make gravity work in the game’s world.


By the end of the workshop, the basic game is in place, and Colaco promises to polish it up so it can be made available on the iTunes and Google stores. The kids are excited to learn that their work will be available for their friends to download and play.


I doubt they will remember the specific details of Action Script in the years to come, but most importantly when they see a page of code they won’t see something baffling and intimidating, like most of us would. They’ll see potential, something you can get your hands into and make magic happen.


Whether or not coding becomes a career, or a hobby, they’ll have a deeper understanding of how software works, as computers increasingly permeate every part of our lives. And they’ve certainly proved one thing: kids can, indeed, code.


Play the Game!


Scan the QR code to try out and download Oinkmaster: Ninja Pirate Pig Pandemonium for freea on the iOS App Store or Google Play (VPN needed). If your kids want to be the game designers of the future, contact Kids Can Code! via Wechat: fcolaco or http://kids.youcancode.net.


Photos: Philip Johnson

This article appeared on p38-40 of beijingkids April 2018 issue


Get your e-copy now!

Long-press the QR code to download the magazine


beijingkids

Follow us on Instagram/Twitter 
@beijingkids

Join the conversation by leaving your comments below. Click/tap Read More to access the hyperlinks in this article.


    您可能也对以下帖子感兴趣

    文章有问题?点此查看未经处理的缓存